Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
node-plop is a tool that allows you to create and manage code generators using a pluggable and customizable approach. It is built on top of plop, which is a micro-generator framework that helps you create consistent and repeatable code structures.
Creating Generators
This feature allows you to create a generator with prompts and actions. The example shows a basic generator that prompts the user for a name and then creates a file using a Handlebars template.
const nodePlop = require('node-plop');
const plop = nodePlop();
plop.setGenerator('basic-generator', {
description: 'this is a basic generator',
prompts: [
{
type: 'input',
name: 'name',
message: 'What is your name?'
}
],
actions: [
{
type: 'add',
path: 'src/{{name}}.js',
templateFile: 'plop-templates/basic.hbs'
}
]
});
plop.getGenerator('basic-generator').runActions({ name: 'example' });
Custom Actions
This feature allows you to define custom actions that can be executed as part of the generator. The example shows how to create a custom action type and use it in a generator.
const nodePlop = require('node-plop');
const plop = nodePlop();
plop.setActionType('customAction', (answers, config, plop) => {
return 'Custom action executed';
});
plop.setGenerator('custom-generator', {
description: 'this is a custom generator',
prompts: [
{
type: 'input',
name: 'name',
message: 'What is your name?'
}
],
actions: [
{
type: 'customAction'
}
]
});
plop.getGenerator('custom-generator').runActions({ name: 'example' });
Using Handlebars Helpers
This feature allows you to add custom Handlebars helpers to your generators. The example shows how to add an 'upperCase' helper and use it in a generator to create a file with an uppercase name.
const nodePlop = require('node-plop');
const plop = nodePlop();
plop.addHelper('upperCase', (text) => text.toUpperCase());
plop.setGenerator('helper-generator', {
description: 'this is a helper generator',
prompts: [
{
type: 'input',
name: 'name',
message: 'What is your name?'
}
],
actions: [
{
type: 'add',
path: 'src/{{upperCase name}}.js',
templateFile: 'plop-templates/helper.hbs'
}
]
});
plop.getGenerator('helper-generator').runActions({ name: 'example' });
Yeoman Generator is a scaffolding tool that allows you to create and manage code generators. It provides a more extensive ecosystem and a larger community compared to node-plop. Yeoman generators are more feature-rich and offer more built-in functionalities, but they can be more complex to set up and use.
Hygen is a fast and lightweight code generator that focuses on simplicity and ease of use. It uses plain JavaScript and EJS templates, making it easy to get started. Compared to node-plop, Hygen is more straightforward but may lack some of the advanced customization options available in node-plop.
Slush is a scaffolding tool that uses Gulp for task automation. It allows you to create and manage code generators with a focus on flexibility and customization. Slush provides a different approach compared to node-plop, leveraging the power of Gulp to handle complex tasks and workflows.
This is an early publication of the plop core logic being removed from the CLI tool. Main purpose for this is to make it easier for others to automate code generation through processes and tools OTHER than the command line. This also makes it easier to test the code functionality of PLOP without needing to test via the CLI interface.
Once I feel comfortable that this code functions as it should. I'll be driving the plop CLI tool using node-plop.
const nodePlop = require('node-plop');
// load an instance of plop from a plopfile
const plop = nodePlop(`./path/to/plopfile.js`);
// get a generator by name
const basicAdd = plop.getGenerator('basic-add');
// run all the generator actions using the data specified
basicAdd.runActions({name: 'this is a test'}).then(function (results) {
// do something after the actions have run
});
FAQs
programmatic plopping for fun and profit
The npm package node-plop receives a total of 842,879 weekly downloads. As such, node-plop popularity was classified as popular.
We found that node-plop demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.